<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>
    <link href="../css/register.css" rel="stylesheet" type="text/css"/>
</head>
<body>
    <div style="margin-top: 100px;margin-left: 27%;width: 800px;height:600px;position: center;background-color: #dddddd;">
        <div class="div" style="margin-top: 10px">
            <label class="label">用户名：</label><input class="input" id="userName" name="userName" type="text" placeholder="请输入用户名">
        </div>
        <div class="div">
            <label class="label">密  码：</label><input class="input" id="password" name="password" type="password" placeholder="请输入密码">
        </div>
        <div class="div">
            <label class="label">姓  名：</label><input class="input" id="realName" name="realName" type="text" placeholder="请输入真实姓名">
        </div>
        <div class="div">
            <label class="label">身份证：</label><input class="input" id="identity" name="identity" type="text" placeholder="请输入身份证号码">
        </div>
        <div class="div">
            <label class="label">联系电话：</label><input class="input" id="phone" name="phone" type="text" placeholder="请输入联系电话">
        </div>
        <div class="div"><input class="btn" type="submit" id="submit" name="submit" value="提交" onclick="registerUser()"></div>
    </div>

    <script type="text/javascript" src="../lib/jquery.min.js"></script>
    <script type="text/javascript">
        function registerUser() {
            var userName = $("#userName").val();
            var password = $("#password").val();
            var realName = $("#realName").val();
            var identity = $("#identity").val();
            var phone = $("#phone").val();
            if(userName == "" || userName == null){

                alert("用户名不能为空！");

            }else if(password == "" || password == null){

                alert("密码不能为空！");
            }else if(realName == "" || realName == null){

                alert("真实姓名不能为空！");

            }else if(identity == "" || identity == null){

                alert("身份证号码不能为空！");

            }else{

                $.ajax({
                    type: "post",
                    url: "/user/insertOne",
                    data: {
                        groupid:1,
                        username:userName,
                        password:password,
                        realname:realName,
                        identity:identity,
                        phone:phone,
                        remark:"测试",
                        status:1

                    },
                    dataType: "json",
                    success: function (data) {
                        var status=data.status;
                        var msg=data.msg;
                        if(status == 0){
                            //parent.window.location.reload();
                            alert(userName+"注册成功！");
                            window.parent.location.href = "admin-index.html";

                        }else{
                            alert(msg);
                        }

                    },
                    fail:function (data) {
                        alert(JSON.stringify(data))
                    },
                    error: function(xhr) {
                        // report error
                        alert('Error' + JSON.stringify(xhr))
                    }
                });






            }

        }

    </script>
</body>




</html>